package info.tsukaworld.gui;

import javax.swing.*;
import acm.program.*;
import acm.graphics.*;
import java.awt.Dimension;
import java.awt.event.*;
import info.tsukaworld.actor.Player;
import java.io.*;

public class Game extends GraphicsProgram //implements KeyListener
{
    private TopHUD thud;
    private BotHUD bhud;
    private PlayArea area;
    private final int RUN_SPEED = 100/6;
    private Player player;
    public static GameMouseListener mouseListener = new GameMouseListener();
    public Game()
    {
        super();
        player = new Player();
        area = new PlayArea(player);
        setTitle("Game");
        addKeyListeners( new GameKeyListener(player) );
        addMouseListeners(mouseListener);
        thud = new TopHUD();
        bhud = new BotHUD();
        add(thud);
        add(area);
        add(bhud);
    }

    public void run()
    {
        while(true)
        {
            area.step();
            thud.step();
            bhud.step();
            pause( RUN_SPEED );
        }
    }

    public Dimension getMinimumSize()
    { return new Dimension((int)(area.getWidth()), ((int)area.getHeight()) + TopHUD.TOP_HUD_HEIGHT + BotHUD.BOT_HUD_HEIGHT); }

    public Dimension getPreferredSize()
    { return getMinimumSize(); }

}
